fix issue #51
fix #49
Merge pull request #54 from emirose/master

fixing issues #51 and #49