Bug fixes. Closes #114, closes #112