Use Java 7 API to make classloader thread safe. Closes #516