Cleanup dead code and reformat