Fixes for #26, #24, #22, #17, #18, and addresses #19