Added validation for reads/writes and fixed some warnings