Merge pull request #30 from dalkon/master

Fixes & additions
Fix possible crashes

This fixes issue #29
Only use one script environment
Merge remote-tracking branch 'upstream/master'