Fixed issues #2, #7, #12.