Some reordering and small fixes