Updated logging and exception handling