Refactor pre-process-expression
Several functions were refactored.