Code Cleanup: Remove #if 0 code

As a personal habit I tend to use the C pre-processor to
comment out code blocks I don't want to remove. This is in
case the code will be required in the future.

I think it is now safe to say the code commented out is not
required -- most of it is legacy and marks the transition from
earlier designs or legacy code.

I've done this in one big commit since in theory it has no
functional change, and in future can look in this commit for any
code we may want to reinstate.