fixed issue #13, #14, #15

Your project is really great but has some bugs. I reported them and I fixed.

Please review the issues and my patch. If there's no problem, accept my pull request.