Some formatting cleanup and moving some code around.