Fixed issues #1, #3, #4.