Fix some variable bugs