Added top-level exception handler and some logging