Replaced console.log with debug logging functionality.