More code shuffling, cleaning and reformatting