Update variables, improve structure