Attempted to make it not use recursion

I also fixed some inefficiencies

unfortunately it didn't really work
Fixed compiler error and raw types
Converted to a Maven project