Replace all panel now automatically refreshes on document change.
Refactoring and fixing JSLint errors.