Fix ff problem and optimize code reuse

Signed-off-by: Andreas Pieber <anpieber@gmail.com>