_lanes = {}
_stacks = {}
_aliases = {}
_last_name = {}


_block_type(block_type)
	
	if block_type == null
		block_type = called-from[1]
	return block_type

_reset_last_name(block_type=null)
	block_type = _block_type(block_type)

	if block_type in _last_name
		remove(_last_name, block_type)


_set_last_name(name, block_type=null)
	block_type = _block_type(block_type)

	_last_name[block_type] = name

_get_last_name(block_type)
	block_type = _block_type(block_type)

	if block_type in _last_name
		return _last_name[block_type]
	else 
		return null


_push_onto_stack(block, block_type=null)
	block_type = _block_type(block_type)

	if block_type in _stacks
		stack = _stacks[block_type]
	else
		stack = ()
	
	push(stack, block)
	_stacks[block_type] = stack

_pop_from_stack(block_type=null)
	block_type = _block_type(block_type)

	if block_type in _stacks
		stack = _stacks[block_type]
		b = pop(stack)
		if length(stack) > 0
			_stacks[block_type]
		else 
			remove(_stacks, block_type)
		return b
	return null

_pop_stack(block_type=null)
	block_type = _block_type(block_type)

	if block_type in _stacks
		stack = _stacks[block_type]
		remove(_stacks, block_type)
		return stack
	else
		return ()
		
_last_element_of_stack(block_type=null)
	block_type = _block_type(block_type)
	
	if block_type in _stacks
		stack = _stacks[block_type]
		return stack[-1]
	else
		return null

_set_lane(lane_name, value, block_type=null)
	block_type = _block_type(block_type)

	if block_type in _lanes
		lane = _lanes[block_type]
	else
		lane = {}

	if lane_name in lane
		stack = lane[lane_name]
	else
		stack = ()

	push(stack, value)
	lane[lane_name] = stack
	_lanes[block_type] = lane
	
_get_lane(block_type)
	block_type = _block_type(block_type)
		
	if block_type in _lanes
		return _lanes[block_type]
	else
		return {}


_put_into_lane(key, value, block_type=null)
	block_type = _block_type(block_type)

	if block_type in _lanes
		lane = _lanes[block_type]
	else
		lane = {}
	
	lane[key] = value
	_lanes[block_type] = lane

_pop_lane(block_type=null)
	block_type = _block_type(block_type)
	
	if block_type in _lanes
		lane = _lanes[block_type]
		remove(_lanes, block_type)
		return lane
	else
		return {}

_set_alias(name, alias, block_type=null)
	block_type = _block_type(block_type)
	
	if block_type in _aliases
		alias_map = _aliases[block_type]	
	else
		alias_map = {}
		
	alias_map[name] = alias
	_aliases[block_type] = alias_map
	
_get_alias(name, block_type=null)
	block_type = _block_type(block_type)
	
	if block_type in _aliases
		alias_map = _aliases[block_type]
		if name in alias_map
			return alias_map[name]
		else
			return name
	else
		return name
		
_reset_aliases()
	for key in keys(_aliases)
		remove(_aliases, key)