Improve handling of common expressions (defined variables)