Fixed read returning wrong values. Small code cleanup.