added a lock on the table loading so that we only refresh the view once after the table gets loaded
cleaned up code and comments