small fixes to use .dat file extension and make the file name processing
more robust. ie, p or P are both possible.