Fix to move to the side the majority of the window is on. Start adding functions and file local variables.