main, parser: fixed --threads parameter, code cleanup