Move variables for clarity and scope
Remove unused variables. Move a few more for clarity