restructure program; add Makefile