Bug fixes in CREAD func