Rearranged some functions.