Refactored term code, added Makefile