I'm not familiar with the algorithm myself, but what I can tell you that your programming methodologies are about as unsafe and bug prone as imaginable.

(1) Never use the "new" operator unless...