Added logging and exception-handling infrastructure