fixed some bugs, optimization
Merge pull request #13 from vrz/master

fixed some bugs, optimization