Fixed issue #15, #12, #13