bugfixes and optimizations for processing depth images