Making code compatible with Java 1.5 and optimizing import