Optimized and fixed reading/writing methods.