guards on buffer/config
fixed empty or null Buffer bug.