Fix type replacement in user defined type. Thanks to Dominique Legendre for the report.
Add rewriting of internal functions in package body, those functions will be prefixed by the package name. Thanks to Dominique Legendre for the feature request.