Cleaned up some variable scopes