makefile / deployment fixes, code restructuring