Moved some code around in different files.