bunch of cleanup and api changes