Refactor integration routines