Move some common stuff away from aftool/bktool mains