Changed some buffer malloc size calculations to use sizeof rather than assumptions.