Code cleanup and addition of "read"/"write" commands