Reorganization and re-factoringing

Tests imcomplete