Cleanup patches

The basis is the large cleanup patch from flatterman.

I've added a few patches on top, that further cleans up the source and ignores files.
This relates primarily to issue #17