added ability to run and display scripts, refactored state