makefile now works for debug and lib targets; many improvements