Marked constructDocument member methods as const
* they don't modifiy the class state so there is no reason for them not being marked as const
** all calling methods are also const
** this enables us to remove the const_cast in FunctionBase
* modified external function implementations accordingly
* inlined handleError method in FunctionTransform as it is not needed in multiple places anymore