some renaming and shuffling of functions