factored out entity lib, moved some tuple magic into Tuples