fix layer 0 bug, change bid2offset to return long