Major code tidy.