Fixed erroneous write/read calls