Updated exceptin handling and logging