some cleanup/commenting, plus changes that fix #50