Fix buffer size calculation
includes
move includeds to header
debugging
add debug info