Rearranged helper functions.