void ConstructProgramState(LoadType loadType, GUI parentGUI, String filterTag){
        //mainGUI.isChangingState = true;
	switch (loadType){
	case Init:
            Settings.setSettingAndSave("databaseFilePathAndName", getSetting("homeDir")+getSetting("databasePathExt")+getSetting("databaseFileName"));
            InitDemoDB.initDB(Settings.getSetting("databaseFilePathAndName"));//Resets database
            Settings.setSettingAndSave("databaseVersion", ImageDatabase.getDatabaseVersion());
	case Load:
	    mainGUI.mainImageDB = new ImageDatabase(getSetting("databaseFileName"),getSetting("databaseFilePathAndName"));
            checkDBVersion();
            //no break as image list must still be passed from DB
	case Refresh:
	    //Create image database by loading database
	    currentFilter = "-1";
	    imageIDs = mainGUI.mainImageDB.getAllImageIDs();
	    break;
        case LoadLast:
            mainGUI.mainImageDB = new ImageDatabase(getSetting("databaseFileName"),getSetting("databaseFilePathAndName"));
            checkDBVersion();
            //change currentI by maingGUI.settings.getSetting("LastCurrentI") but be careful of null, etc.
	case Filter:
	    //Create image database by loading database
            if(filterTag==null) {
                log.print(LogType.Error,"Error: Tried to filter by tag without a filter.");
                ConstructProgramState(LoadType.Load, parentGUI, "");
                return;
            } else if (filterTag.equals("-1")){
                ConstructProgramState(LoadType.Refresh, parentGUI, filterTag);
                return;
            }
	    currentFilter = filterTag;
	    imageIDs = mainGUI.mainImageDB.getImageIDsFromTagIDChildren(filterTag); // Working on TagID not TagTitle
	    break;
	}
        Settings.setSettingAndSave("lastFilterUsed", currentFilter);
	//if imageIDs.length==0
	//then a file should be added first (Construct with Init&imports, then return;)
      	imageList = new ImageReference[imageIDs.length];
        numberOfImages = imageList.length;
	for(int i=0; i<imageIDs.length;i++){
	    imageList[i] = new ImageReference(mainGUI.mainImageDB.getImageFilename(imageIDs[i]));
	}
	lastIndex = (imageIDs.length - 1);

        //mainGUI.isChangingState = false; //Set false before calling imageChanged thumbPanel.onResize() waits for this to be false
        //Needed as GUI components not cfreated yet
	//if((loadType!=LoadType.Init) && (loadType!=LoadType.Load)){
            //imageChanged();//Will cause deadlock or bugs if uncommented. Call after constructing
	//}
    if(imageList.length<1){
            log.print(LogType.DebugError,"Error: There are no images loaded under current search.\nEnsure filter has some images.");
            imageIDs = new String[1];
            imageIDs[0] = "-1";
            imageList = new ImageReference[1];
            imageList[0] = new ImageReference("NoExistingFiles:a:b:c:d:e:f:g:h.i.j.k.l.m.n:o:p:non.ex");
        }

        imageChanged();
    }