95% of this is fixing the whitespace issues, the remaining 3 lines are the real fix :)

\o/