Cleaned up some local variables and inline some others. No functionality changed.