Mem manager fixes, and added ground/sky/map changing to ray caster.