Rename some locals
Rearrange some lines