Added most of helper functions back.