More deduplication of code