Cleaning up and formatting code