Note: I've struck through the bits I'd remove, and italicized things I'd add for cleanup. Hope this helps!
Note: Inline comments are left in bold.