Cleanup and depth handling.