fixed casting that caused compilation errors with JDK7