Fixed not to cause an exception in paging.
Enhanced to handle environment variables.