bfi: Avoid divisions by zero