Replaced Long.compare() with JDK 6 compatible code