refactor, fixup, comments