Cleaned up some stuff and put in some comments