more consistent types, some bounds checking