more writing and some cleanup