work in progress to fix the bug2989
made some changes so that the navigation history can function corect
some changes into the removeFile method
some redundancy changes made here
Merge pull request #3010 from albualexandru/history-bug

History bug regarding #2989 and #2963