Cleaned up refresh code to make it a bit faster