added makefile and more refactoring