lots of bit twiddling, basic cover tree