Fix for JDK 1.6 and code cleanup