refactor, cleanup, fix #42