Fixed issues #3, #4, #5, and #7.