logging and exception handling improvements