some changes to catch 404 and 412 exceptions.