Changes to accomodate increasing topology size and corrected few logic errors