some bugfixes, some restructuring. TODO: fix this new ugly check3D
structure. I hate it...