refactored buffer handler, logging and messages