added debug wrapper to all functions