Code cleaned up and updated to Java 6 standard