Improve filtering of runtime classpath, and fix an annoying stacktrace on shutdown.