improved makefile
minor bug fixes