[#43] Adds some error handling and logging