Const correct writes

Fix write functions to be const-correct