assorted changes to clean up the code