Tidy up

fixes a number of issues: #36 #27 #29 #31 #32