a bunch of cleanups and additional writing