Fix issues #46 and #47