depth_flag and alpha_flag termination added, tested