Move window initialization and reseting to functions in view.*