cleaned up segment handling
two passes assembly