Fixed issues #19, #20, and #21