Change order of update functions, code formatting