Rewritten and improved generation of use statements