Moved some code around, also added file descriptions