Fixed some variable manipulation issues