Added some comments and renamed the sread and swrite functions