Some more reordering and fixes