Fix some bugs in reader