Fix deprecated method and JDK5