Moved more code around