Update formatting and clean up code