Clean up and tweaks for a non-java version