Cleanup and prep for Scala rewrite.