Fixes for #27, #25, #24