make some counter variables unsigned, use ast_tvcmp instead of a custom