Fixes for issues #44, issue #43, issue #42, issue #38