Order, clean up and comment the code