Bugfixes in occlusion checking, move to ES