Refactored scripting system to make additions easier. Added serialization test.