Optimize write/read delimited + minor fixes