Some cleanup

Hi,

I've been doing some cleanup of the code. You might want to have a look.

Maybe we can discuss some of the changes if you want to?