tabgen: finished command line argument validation, added resource cleanup