refactor RTL & numerics code