Corrected and improved update().