add Makefile, brd code refactoring