Fixed a bug with maintaining scroll position when layout optimization was in use.