Added Makefile, fixed BSD algorithm.