Fix issues #283, #284 and #285