Final version of update detection and code clean-up.