Fixed some buffer issues