refactored to use templates to be more portable, now uses makefile to set up nearly everything