Fixed race changing to clean up code/make more efficient.