Attempt at making the code style more consistent.

I'm in the process of getting familiar with the code.

I actually found potential problems with an allocation, but without a proper test environment and doing this on my lunch time, I can't investigate further.

I made some changes while reading for small inconsistencies with the style chosen.
Please accept this contribution for now.

Cheers,
Alex.