Minor changes - renamed/reorganized some functions