Fix variable naming and move some code