added  debug option to makefile
fixed bugs with overflowing buffers and added debug printfs