Minor refactor where some inner classes were moved out into their own files. Also better data-hiding in the InstanceWrapper.