Improved the writing of debug data to functions