Cleaned and refactored. Only runs on Java 7 now