Major refactoring under works.

Part of me is sad that I'm abusing reflection a little bit, but there
are so many attributes and there are limits to how much code duplication
I'm willing to put up with.