Formatted and cleaned up code
Fixed Java warnings