Fixes for #51, #52, #57, #60, #61, #62