Rearranged functions for better continuity.