Added: Error handling and debug support