Add support of 'PAGER' env variable and remove mem leak