Fixed crash.
Merge pull request #306 from tfili/master

Fixed memory corruption