Fix calculating the most recent changes.
Style
Fix undefined variable.