reduced scope of some loop vars
dont remember
fixed redraw bug when panning while a tool is active
removed unnecessary copying