Fixed issues #24, #5, #28.