Refactored. Now fully java