work around https://code.google.com/p/chromium/issues/detail?id=341598
fix a bug reading the end of the buffer + use more descriptive variables
fix copy/paste error
Merge branch 'master' into framework