Added some exports and reorganized functions.