Fixed some variable names to make the threading work