Miscellaneous bug fix

Now the code is able to run custom scripts without any futher problems.