consolidate function

Various low-level helper functions