Re-ordered few functions to improve organization.