minor refactoring of many things