pass X by reference in integration, use result_of instead of typeof -- related to #460