Check broken input
Better alloc heuristic.
Cleanup and use IndexByte where it makes sense.