Fixed issue #7, issue #8, issue #9 and issue #10