Fixing several bugs

Fixes bugs
* with incorrect checking for invalid variable content,
* with getting the script's storage location incorrectly