Renamed and reorganized functions