Add write implementation

Also make some protocols private