Some major cleaning-up and extending