added write functionality, minor fixes for other functions such as path names