improved implementation of DFF, and other small changes