Fixes to some minor bugs.

Closes #335.
Closes #336.
Closes #337.
Closes #340.
Closes #343.
Closes #344.