Reorder some code sections