Fixing issues #54 and #78

Please see individual commits description, thanks!