Changed all the read/writes to use sizeof the variable instead of type of the variable