cleanup and documentation. Added argparse. Makes print-atable obsolete with the -a option in this script.