Fixed buffer read bug. Further logging improvements.