main, get_args, extract_database and extract_table refactorized.