Finished the read() method and did some cleanup/deduplication.