Refactoring expression compiling function.