Added support for simplification of average functions and improved simplification of division function. #1026.