Some reshuffling of needed functions to prevent duplication