The keyval functions should really be generic, and the window property api should be completely revisited, but for now this will allow us to proceed.
At the same time, move some more class and instance structs out of public headers.