Added error handling and logging to the proxy.