fixes #27 #28 and addresses (i think) #18