fixed warning

sizeof returns size_t
reworked code with less memory allocations

after several experiments with data rearrangement, the code that was in
the standard implementation was the best for readability