Fix variables, update inputs to improve code layout