Script clean-up

Cleaned up both scripts, all relevant code is now only executed when script is not used as module but run by itself. More clean-up and renaming to follow.