Back-port to Java6 build, and other build improvements.