added switch to go back n days and did a bit of cleanup