Fixed up as much as possible
Delimited bad code with comments