Some code rearraging