Fix issue 112 etc

Fixes #112 and two other issues.