Fixed some variable declaration bugs