Some cleaning up before more serious updates

To avoid whitespace changes cluttering real work later on here's some cleanup:
- made indentation consistent (tabs)
- stripped (most obvious) extra empty lines and eol whitespace
- made if-spacing consistent (and foreach etc)

This is just to get the big picture together - I tried not to go into details too much =).

And now back to fixing a couple of things. I'll continue from this state, so let me know if you don't agree with my cleaning up. Have a great weekend!