Replace redundant code with function calls.