Small changes.
Mofified read to match working C version