Fixed Read/Write functions
Fixed compilation errors