Moved all imports to the top as well as all function definitions. Changed the paths to work with relative paths within the repo. Otherwise the code is unchanged.