Re-organized to work with Maven
Fixed multiple bugs.