Cleaned up source and fixed several problems concerning the ordering of
the update operation.