Clean up some code, add some notes