Fixed file writing in fetch_update and proper exception handling in models