added better exception handling and logging, plus notifications for errors