Added bugs, improvements and additional checks
Merge pull request #1 from maxim123/master

Added bugs, improvements and additional checks