indentation is all weird, here and in the function below.

Select the code and do Ctrl-K, Ctrl-F (if you're using VS). First make sure you've set VS to use real tabs, width 2, though.