Fixed bugs in read-in