Update restclient.main.js with local changes.

Added some minor tweaks to handle various scenarios brought up by users.