Reorganize the code and add a Makefile.