bug fixes, added export read and write functions