switched to gen.Span and some minor improvements