Some clean up and reactoring.