Cleaning up some scoping and making object names consistent