Consolidate some scoped code