Move the definitions to the header again, but provide them at global scope.

This should fix the previous problem too, and keeps related declarations/definitions together.
Fixed more declarations to define their members at global scope.