Moved some code around.