[BUGFIX] Page detection fails in edge cases