small changes to some functions and more writing