Organize code and add a template Makefile