fixed crash issues
Merge pull request #4 from Scarabol/master

fixed crash issues 
Thanks Scarabol!