finished initial breakout of code into functions. some of them should go in /etc/byz_func.sh.