Small bug fixes.
Fixes #187
Fixes #186
Fixes #184
Fixes #183