Partial fix to freeze when calling read() bug.