Cleaning up some variables, adding documentation