Massive source restructuring and new Makefile