refactoring the FX core engine; reducing complexity