moved things around a lot; sped up maxwell dist generation by precomputing list.