don't use hardcoded dimensions in buffer size computation
just shuffling and removing junk