Fix bugs in os_pages update hook

From #3844.