This Fixes #952

1>The removal of old pager in case of error is done.
2>For the lexical error . The string replacement I have done using regex is a crude way. Need to get a better way to handle this.
@gordonwoodhull you can review this and let me know if you feel there is another better way.