Completely revised implementation of the foreground operator