put all functions except main in separate file, updated header and makefile.