Fix and speed-up

Fix for bug and small speed-up of code for reading data, removed
temporary buffer.