Cleaned up java code