This fixes issues #6, #7, #32