Reorganized some stuff to facilitate the new interface