Full code reformat and cleanup