Added error checking on connection, also login check on refresh
Merge