Finished the export code (need some clean up though)