improved debug support and error handling