Fixed crashing problem (depth was not getting reset each cycle)