Fix for issues #8, #9, #10