some cleanup and refactoring
added some pedagogical logging
update