Reorganized. Added debug docs.