Cleanup of code

I know it's called dirty but this is easier to understand.