Various bugfixes (closes #237, closes #236, closes #233)