Fixed silly bug

Fixes #340
Fixes #339
Fixes #338