Cleaned up some code and changed some variable/function names.