Built prior functionality into new code.

Still has issues with banding/spots in the AND mask