Off by one error in the UI restoration function
Working restoration of GUI state