Re-format and cleanup the code