Reorganized internals a bit.