Refactor static learning preprocessing pass (#1857)