adding function name to debug macros
improving debug and error output