makefile added, some refactoring