Fix bug in fixedfx r2; improve code to avoid similar bugs