diff --git a/src/snc/analysis.c b/src/snc/analysis.c
index c6d4bef2b21b046854a084757f2e113bdce9ff3f..f999d393b1b38c85c19b647d0b3a1db0d1fa2b7e 100644
--- a/src/snc/analysis.c
+++ b/src/snc/analysis.c
@@ -222,7 +222,7 @@ static void analyse_definitions(Program *p)
 static void analyse_option(Options *options, Expr *defn)
 {
 	char	*optname;
-	int	optval;
+	uint	optval;
 
 	assert(options);		/* precondition */
 	assert(defn);			/* precondition */
@@ -257,7 +257,7 @@ static void analyse_option(Options *options, Expr *defn)
 static void analyse_state_option(StateOptions *options, Expr *defn)
 {
 	char	*optname;
-	int	optval;
+	uint	optval;
 
 	assert(options);		/* precondition */
 	assert(defn);			/* precondition */
@@ -1132,7 +1132,7 @@ static void connect_variables(SymTable st, Expr *scope)
 #ifdef DEBUG
 	report("**begin** connect_variables\n");
 #endif
-	traverse_expr_tree(scope, 1<<E_VAR, ~has_sub_expr_mask,
+	traverse_expr_tree(scope, 1u<<E_VAR, ~has_sub_expr_mask,
 		0, connect_variable, &st);
 #ifdef DEBUG
 	report("**end** connect_variables\n");
@@ -1141,15 +1141,15 @@ static void connect_variables(SymTable st, Expr *scope)
 
 void traverse_expr_tree(
 	Expr		*ep,		/* start expression */
-	int		call_mask,	/* when to call iteratee */
-	int		stop_mask,	/* when to stop descending */
+	uint		call_mask,	/* when to call iteratee */
+	uint		stop_mask,	/* when to stop descending */
 	Expr		*scope,		/* current scope, 0 at top-level */
 	expr_iter	*iteratee,	/* function to call */
 	void		*parg		/* argument to pass to function */
 )
 {
 	Expr	*cep;
-	int	i;
+	uint	i;
 	int	descend = TRUE;
 
 	if (!ep)
@@ -1161,7 +1161,7 @@ void traverse_expr_tree(
 #endif
 
 	/* Call the function? */
-	if (call_mask & (1<<ep->type))
+	if (call_mask & (1u<<ep->type))
 	{
 		descend = iteratee(ep, scope, parg);
 	}
@@ -1184,7 +1184,7 @@ void traverse_expr_tree(
 	{
 		foreach (cep, ep->children[i])
 		{
-			if (cep && !((1<<cep->type) & stop_mask))
+			if (cep && !((1u<<cep->type) & stop_mask))
 			{
 				traverse_expr_tree(cep, call_mask, stop_mask,
 					scope, iteratee, parg);
@@ -1195,7 +1195,7 @@ void traverse_expr_tree(
 
 static int assign_next_delay_id(Expr *ep, Expr *scope, void *parg)
 {
-	int *delay_id = (int *)parg;
+	uint *delay_id = (uint *)parg;
 
 	assert(ep->type == E_DELAY);
 	ep->extra.e_delay = *delay_id;
@@ -1207,12 +1207,12 @@ static int assign_next_delay_id(Expr *ep, Expr *scope, void *parg)
 static uint connect_states(SymTable st, Expr *prog)
 {
 	Expr	*ssp;
-	int	num_ss = 0;
+	uint	num_ss = 0;
 
 	foreach (ssp, prog->prog_statesets)
 	{
 		Expr *sp;
-		int num_states = 0;
+		uint num_states = 0;
 
 #ifdef DEBUG
 		report("connect_states: ss = %s\n", ssp->value);
@@ -1249,7 +1249,7 @@ static uint connect_states(SymTable st, Expr *prog)
 		{
 			Expr *tp;
 			/* Each state has its own delay ids */
-			int delay_id = 0;
+			uint delay_id = 0;
 
 			foreach (tp, sp->state_whens)
 			{
@@ -1273,7 +1273,7 @@ static uint connect_states(SymTable st, Expr *prog)
 					ssp->value, sp->value, tp->value, next_sp->extra.e_state->index);
 #endif
 				/* assign delay ids */
-				traverse_expr_tree(tp->when_cond, 1<<E_DELAY, 0, 0,
+				traverse_expr_tree(tp->when_cond, 1u<<E_DELAY, 0, 0,
 					assign_next_delay_id, &delay_id);
 			}
 			if (delay_id > ssp->extra.e_ss->num_delays)
@@ -1347,7 +1347,7 @@ static void connect_state_change_stmts(SymTable st, Expr *scope)
 	csc_arg.ssp = 0;
 	csc_arg.in_when = FALSE;
 	traverse_expr_tree(scope,
-		(1<<S_CHANGE)|(1<<D_SS)|(1<<D_ENTEX)|(1<<D_WHEN),
+		(1u<<S_CHANGE)|(1u<<D_SS)|(1u<<D_ENTEX)|(1u<<D_WHEN),
 		expr_mask, 0, iter_connect_state_change_stmts, &csc_arg);
 }
 
@@ -1381,7 +1381,7 @@ static void mark_states_reachable_from(Expr *sp)
 
 	traverse_expr_tree(
 		sp,				/* start expression */
-		(1<<S_CHANGE)|(1<<D_WHEN),	/* when to call iteratee */
+		(1u<<S_CHANGE)|(1u<<D_WHEN),	/* when to call iteratee */
 		expr_mask,			/* when to stop descending */
 		sp,				/* current scope, 0 at top-level */
 		iter_mark_states_reachable,	/* function to call */
@@ -1421,7 +1421,7 @@ static void check_states_reachable_from_first(Expr *ssp)
 static uint assign_ef_bits(Expr *scope)
 {
 	Var	*vp;
-	int	num_event_flags = 0;
+	uint	num_event_flags = 0;
 	VarList	*var_list;
 
 	var_list = *pvar_list_from_scope(scope);
diff --git a/src/snc/analysis.h b/src/snc/analysis.h
index 0c17fd5e16747d255c38502a4e7995f274101423..2b981afcf7924e8d3c85098e2ef61e5526c2bcc1 100644
--- a/src/snc/analysis.h
+++ b/src/snc/analysis.h
@@ -31,8 +31,8 @@ typedef int expr_iter(Expr *ep, Expr *scope, void *parg);
 
 void traverse_expr_tree(
 	Expr		*ep,		/* start expression */
-	int		call_mask,	/* when to call iteratee */
-	int		stop_mask,	/* when to stop descending */
+	uint		call_mask,	/* when to call iteratee */
+	uint		stop_mask,	/* when to stop descending */
 	Expr		*scope,		/* current scope, 0 at top-level */
 	expr_iter	*iteratee,	/* function to call */
 	void		*parg		/* argument to pass to function */
diff --git a/src/snc/expr.c b/src/snc/expr.c
index f9780f1c08a5ec676b24cb86a14a90b35ef86740..bb21df051cc9d6e30c08e50739569643b510f446 100644
--- a/src/snc/expr.c
+++ b/src/snc/expr.c
@@ -28,7 +28,7 @@ static const StateOptions default_state_options = DEFAULT_STATE_OPTIONS;
 
 /* Expr is the generic syntax tree node */
 Expr *expr(
-	int	type,
+	uint	type,
 	Token	tok,
 	...			/* variable number of child arguments */
 )
diff --git a/src/snc/expr.h b/src/snc/expr.h
index 6cf68f69a37bffea59c7f3b3d6147e878df0763c..c615c0f2cd202095abc3aba9b4bd47a9c9078cc6 100644
--- a/src/snc/expr.h
+++ b/src/snc/expr.h
@@ -16,7 +16,7 @@ in the file LICENSE that is included with this distribution.
 #include "types.h"
 
 Expr *expr(
-	int	type,		/* E_BINOP, E_ASGNOP, etc */
+	uint	type,		/* E_BINOP, E_ASGNOP, etc */
 	Token	tok,		/* "==", "+=", var name, constant, etc. */
 	...
 );
diff --git a/src/snc/gen_ss_code.c b/src/snc/gen_ss_code.c
index 004a41c37918c61635d811a58410b8dc6a552e1a..070059c961f2580ffe851f59f9c1ef295d5405f9 100644
--- a/src/snc/gen_ss_code.c
+++ b/src/snc/gen_ss_code.c
@@ -247,7 +247,7 @@ static void gen_delay_body(Expr *xp)
 	foreach (tp, xp)
 	{
 		assert(tp->type == D_WHEN);
-		traverse_expr_tree(tp->when_cond, 1<<E_DELAY, 0, 0, gen_delay, 0);
+		traverse_expr_tree(tp->when_cond, 1u<<E_DELAY, 0, 0, gen_delay, 0);
 	}
 }
 
@@ -368,7 +368,7 @@ static void gen_var_access(Var *vp)
 	report("var_access: %s, scope=(%s,%s)\n",
 		vp->name, expr_type_name(vp->scope), vp->scope->value);
 #endif
-	assert((1<<vp->scope->type) & scope_mask);
+	assert((1u<<vp->scope->type) & scope_mask);
 
 	if (vp->type->tag == V_EVFLAG)
 	{
@@ -627,7 +627,7 @@ static int gen_builtin_func(int context, Expr *ep)
 static void gen_ef_arg(
 	const char	*func_name,	/* function name */
 	Expr		*ap,		/* argument expression */
-	int		index		/* argument index */
+	uint		index		/* argument index */
 )
 {
 	Var	*vp;
diff --git a/src/snc/gen_tables.c b/src/snc/gen_tables.c
index 436e222b4fe01c9247577b6283a33cff9f642399..7f8f63de88d8f58e559e80c8e8f58c3a715071ae 100644
--- a/src/snc/gen_tables.c
+++ b/src/snc/gen_tables.c
@@ -31,7 +31,7 @@ in the file LICENSE that is included with this distribution.
 
 typedef struct event_mask_args {
 	seqMask	*event_words;
-	int	num_event_flags;
+	uint	num_event_flags;
 } event_mask_args;
 
 static void gen_channel_table(ChanList *chan_list, uint num_event_flags, int opt_reent);
@@ -373,7 +373,7 @@ static int iter_event_mask_scalar(Expr *ep, Expr *scope, void *parg)
 	event_mask_args	*em_args = (event_mask_args *)parg;
 	Chan		*cp;
 	Var		*vp;
-	int		num_event_flags = em_args->num_event_flags;
+	uint		num_event_flags = em_args->num_event_flags;
 	seqMask		*event_words = em_args->event_words;
 
 	assert(ep->type == E_VAR);
diff --git a/src/snc/main.c b/src/snc/main.c
index fa8f5c5c09c64ecdb3752959a3baefa37225b875..d4b322cc2b080b3a07709853af6b18cd96cfdbf1 100644
--- a/src/snc/main.c
+++ b/src/snc/main.c
@@ -155,7 +155,7 @@ static void parse_args(int argc, char *argv[])
 
 static void parse_option(char *s)
 {
-	int		opt_val;
+	uint		opt_val;
 
 	opt_val = (*s == '+');
 
diff --git a/src/snc/snl.re b/src/snc/snl.re
index 7797f58d3fc724fcf9c412a8a0147cc918b162f5..dc37b629ff562c4e62b314b39e589ba50984d90b 100644
--- a/src/snc/snl.re
+++ b/src/snc/snl.re
@@ -83,13 +83,15 @@ static uchar *fill(Scanner *s, uchar *cursor) {
 	/* does not touch s->cur, instead works with argument cursor */
 	if (!s->eof) {
 		uint read_cnt;			/* number of bytes read */
-		uint garbage = s->tok - s->bot;	/* number of garbage bytes */
-		uint valid = s->lim - s->tok;	/* number of still valid bytes to copy */
+		int garbage = s->tok - s->bot;	/* number of garbage bytes */
+		int valid = s->lim - s->tok;	/* number of still valid bytes to copy */
 		uchar *token = s->tok;		/* start of valid bytes */
-		uint space = (s->top - s->lim) + garbage;
+		int space = (s->top - s->lim) + garbage;
 						/* remaining space after garbage collection */
 		int need_alloc = space < BSIZE;	/* do we need to allocate a new buffer? */
 
+		assert(valid >= 0);
+
 		/* anything below s->tok is garbage, collect it */
 		if (garbage) {
 #ifdef DEBUG
@@ -97,7 +99,7 @@ static uchar *fill(Scanner *s, uchar *cursor) {
 #endif
 			if (!need_alloc) {
 				/* shift valid buffer content down to bottom of buffer */
-				memmove(s->bot, token, valid);
+				memmove(s->bot, token, (size_t)valid);
 			}
 			/* adjust pointers */
 			s->tok = s->bot;	/* same as s->tok -= garbage */
@@ -110,11 +112,14 @@ static uchar *fill(Scanner *s, uchar *cursor) {
 		/* increase the buffer size if necessary, ensuring that we have
 		   at least BSIZE bytes of free space to fill (after s->lim) */
 		if (need_alloc) {
-			uchar *buf = (uchar*) malloc((s->lim - s->bot + BSIZE)*sizeof(uchar));
+			uchar *buf;
+
+			assert(s->lim - s->bot >= 0);
+			buf = (uchar*) malloc(((size_t)(s->lim - s->bot) + BSIZE)*sizeof(uchar));
 #ifdef DEBUG
 			report("fill: need_alloc, bot: before=%p after=%p\n", s->bot, buf);
 #endif
-			memcpy(buf, token, valid);
+			memcpy(buf, token, (size_t)valid);
 			s->tok = buf;
 			s->end = &buf[s->end - s->bot];
 			s->ptr = &buf[s->ptr - s->bot];
@@ -338,8 +343,9 @@ string_cat:
 				goto string_cat;
 			}
 	["]		{
-				uint len = s->end - s->tok;
-				memmove(cursor - len, s->tok, len);
+				int len = s->end - s->tok;
+				assert(len >= 0);
+				memmove(cursor - len, s->tok, (size_t)len);
 				s->tok = cursor - len;
 				goto string_const;
 			}
diff --git a/src/snc/types.h b/src/snc/types.h
index 20a4ab97447bddefd643191b5788d79b0cdfeef7..7d5accb71ce705697a89c96985f258aa629556dc 100644
--- a/src/snc/types.h
+++ b/src/snc/types.h
@@ -93,7 +93,7 @@ struct when				/* extra data for when clauses */
 
 struct state				/* extra data for state clauses */
 {
-	int		index;		/* index in array of seqState structs */
+	uint		index;		/* index in array of seqState structs */
 	uint		is_target;	/* is this state a target state? */
 	StateOptions	options;	/* state options */
 	VarList		*var_list;	/* list of 'local' variables */
@@ -101,8 +101,8 @@ struct state				/* extra data for state clauses */
 
 struct state_set			/* extra data for state set clauses */
 {
-	int		num_states;	/* number of states */
-	int		num_delays;	/* number of delays */
+	uint		num_states;	/* number of states */
+	uint		num_delays;	/* number of delays */
 	VarList		*var_list;	/* list of 'local' variables */
 };
 
@@ -111,7 +111,7 @@ struct expression			/* generic syntax node */
 	Expr		*next;		/* list node: next expression */
 	Expr		*last;		/* list node: last expression */
 	Expr		**children;	/* array of children [left,right,...] */
-	int		type;		/* expression type (E_XXX) */
+	uint		type;		/* expression type (E_XXX) */
 	char		*value;		/* operator or value string */
 	int		line_num;	/* originating line number */
 	const char	*src_file;	/* originating source file */
@@ -119,8 +119,8 @@ struct expression			/* generic syntax node */
 	{
 		Var	*e_var;		/* variable definiton */
 		Var	*e_decl;	/* variable definiton */
-		int	e_delay;	/* delay id */
-		int	e_option;	/* option value (1 or 0) */
+		uint	e_delay;	/* delay id */
+		uint	e_option;	/* option value (1 or 0) */
 		VarList	*e_prog;	/* top-level definitions */
 		StateSet *e_ss;		/* state set data */
 		State	*e_state;	/* state data */
@@ -237,27 +237,29 @@ struct program
 
 /* Expression types that are scopes. By definition, a scope is an expression
    that allows variable declarations as (immediate) subexpressions. */
-#define scope_mask		( (1<<D_PROG) | (1<<D_SS) | (1<<D_STATE)\
-				| (1<<D_ENTEX) | (1<<D_WHEN) | (1<<S_CMPND) )
-#define is_scope(e)		(((1<<((e)->type)) & scope_mask) != 0)
+#define scope_mask		( (1u<<D_PROG)   | (1u<<D_SS)      | (1u<<D_STATE)\
+				| (1u<<D_ENTEX)  | (1u<<D_WHEN)    | (1u<<S_CMPND) )
+
+#define is_scope(e)		(((1u<<((e)->type)) & scope_mask) != 0)
+
 /* Expressions types that may have sub-scopes */
-#define has_sub_scope_mask	( (1<<D_ENTEX) | (1<<D_PROG) | (1<<D_SS)\
-				| (1<<D_STATE) | (1<<D_WHEN) | (1<<S_CMPND) | (1<<S_FOR)\
-				| (1<<S_IF) | (1<<S_STMT) | (1<<S_WHILE) )
+#define has_sub_scope_mask	( (1u<<D_ENTEX)  | (1u<<D_PROG)    | (1u<<D_SS)\
+				| (1u<<D_STATE)  | (1u<<D_WHEN)    | (1u<<S_CMPND)  | (1u<<S_FOR)\
+				| (1u<<S_IF)     | (1u<<S_STMT)    | (1u<<S_WHILE) )
 /* Expressions types that may have sub-expressions */
-#define has_sub_expr_mask	( (1<<D_DECL) | (1<<D_ENTEX) | (1<<D_PROG)\
-				| (1<<D_SS) | (1<<D_STATE) | (1<<D_SYNC) | (1<<D_SYNCQ)\
-				| (1<<D_WHEN) | (1<<E_BINOP) | (1<<E_DELAY) | (1<<E_FUNC)\
-				| (1<<E_INIT) | (1<<E_PAREN) | (1<<E_POST)\
-				| (1<<E_PRE) | (1<<E_SUBSCR) | (1<<E_TERNOP) | (1<<E_VAR)\
-				| (1<<S_CHANGE) | (1<<S_CMPND) | (1<<S_FOR) | (1<<S_IF)\
-				| (1<<S_STMT) | (1<<S_WHILE) )
+#define has_sub_expr_mask	( (1u<<D_DECL)   | (1u<<D_ENTEX)   | (1u<<D_PROG)\
+				| (1u<<D_SS)     | (1u<<D_STATE)   | (1u<<D_SYNC)   | (1u<<D_SYNCQ)\
+				| (1u<<D_WHEN)   | (1u<<E_BINOP)   | (1u<<E_DELAY)\
+				| (1u<<E_FUNC)   | (1u<<E_INIT)    | (1u<<E_PAREN)  | (1u<<E_POST)\
+				| (1u<<E_PRE)    | (1u<<E_SUBSCR)  | (1u<<E_TERNOP) | (1u<<E_VAR)\
+				| (1u<<S_CHANGE) | (1u<<S_CMPND)   | (1u<<S_FOR)    | (1u<<S_IF)\
+				| (1u<<S_STMT)   | (1u<<S_WHILE) )
 /* Expression types that are actually expressions i.e. no definitions or statements.
    These are the ones that start with E_. */
-#define	expr_mask		( (1<<E_BINOP) | (1<<E_CONST) | (1<<E_DELAY) | (1<<E_FUNC)\
-				| (1<<E_INIT)\
-				| (1<<E_PAREN) | (1<<E_POST) | (1<<E_PRE) | (1<<E_STRING)\
-				| (1<<E_SUBSCR) | (1<<E_TERNOP) | (1<<E_VAR) | (1<<T_TEXT) )
+#define	expr_mask		( (1u<<E_BINOP)  | (1u<<E_CONST)   | (1u<<E_DELAY)\
+				| (1u<<E_FUNC)   | (1u<<E_INIT)\
+				| (1u<<E_PAREN)  | (1u<<E_POST)    | (1u<<E_PRE)    | (1u<<E_STRING)\
+				| (1u<<E_SUBSCR) | (1u<<E_TERNOP)  | (1u<<E_VAR)    | (1u<<T_TEXT) )
 
 #define expr_type_name(e)	expr_type_info[(e)->type].name
 
@@ -370,7 +372,7 @@ extern
 struct expr_type_info
 {
 	const char *name;
-	const int num_children;
+	const uint num_children;
 }
 expr_type_info[]
 #ifdef expr_type_GLOBAL