read m_pStream only one time per function and made it volatile to avoid possible race conditions
Fix crystal drift and error in memcpy size calculation