improved exceptionhandling and logging