Changed ordering of some code.