Changed behaviors of paging maths to avoid raising exceptions, use nil as invalid values