Made some changed in Territory and cleaned up code