public void removeDownload(final int gid) {

        // Deletion of download is different for different sates
        switch (downloads.get(gid).getStatus()) {
        case COMPLETE:
        case ERROR:
        case REMOVED:
            taskManager.removeDownloadResult(gid);
            break;

        case NEW:
        case ACTIVE:
        case WAITING:
        case PAUSED:
        case UNKNOWN:
            taskManager.remove(gid);
            break;
        }

    }