Various fixes

* Fixing #1081
* Fixing #1079