Use simpler, slighly more self-explanatory calculation.
Fix two bugs.

Fix bug when reading with no children yet present (just fill in empty bits). Fix bug calculating offset when writing from a bit array.