Moved functions around to try to fix a runtime problem with error handling