added output, bug fixes, optimizations, improved makefile