Removed unneeded module references and imports. Moved a couple functions around and trimmed some dead functions.