Fixed a bug which led to invalid reads