Improve validation of reader and writer