Refactored the code a bit and added a top level makefile