Some bug fixes for #96