further abstraction, cleanup and tweaks