Fixed some issues

Issue #19, #20, #21.