Corrected bugs, cleaner java