diff --git a/NAMESPACE b/NAMESPACE
index ec49d636bb38ba31aa5e0927b310bd99501641fe..ce256da43262c13fd6b7215ba2dcc6ddbac69004 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -35,7 +35,6 @@ export(plot_struct_nowrap)
 export(prescreen)
 export(r2datatab)
 export(read_rt)
-export(refresh_state)
 export(report)
 export(rev2list)
 export(rt_input)
diff --git a/R/api.R b/R/api.R
index e1586a471c992e06beafb2d7bded99faa1656295..78afd5b72e1e278dbe655344088e3649dff070a4 100644
--- a/R/api.R
+++ b/R/api.R
@@ -678,22 +678,24 @@ prepare_app <- function(dir_before,
                         top_data_dir,
                         metfrag_db_dir,
                         metfrag_runtime) {
+
+    ## Information that needs to be availabe to the shiny server.
     init <- list()
     init$dir_before <- dir_before
     init$top_data_dir <- norm_path(top_data_dir)
     init$projects <- norm_path(projects)
-    init$metfrag_db_dir <- if (nchar(norm_path(metfrag_db_dir))>0L) norm_path(metfrag_db_dir) else ""
-    init$metfrag_runtime <- if (nchar(norm_path(metfrag_runtime))>0L) norm_path(metfrag_runtime) else ""
-    
-    if (!dir.exists(init$top_data_dir)) stop(errc_top_data_dir_absent)
-    if (!dir.exists(init$projects)) stop(errc_projects_absent)
+    init$envopts = envopts(metfrag_db_dir=metfrag_db_dir,
+                           metfrag_jar=metfrag_runtime)
 
-    if (nchar(init$metfrag_db_dir)>0L && !dir.exists(init$metfrag_db_dir)) stop(errc_mf_db_dir_absent)
-    if (nchar(init$metfrag_runtime)>0L && !file.exists(init$metfrag_runtime)) stop(errc_mf_jar_absent)
-    
+    check_dir_absent(init$top_data_dir,what="top-data-dir")
+    check_dir_absent(init$projects,what="projects")
+
+
+    ## Create independent starting `home' for the server.
     dir_start <- tempfile("shinyscreen")
     dir.create(dir_start, recursive = T)
 
+    ## Copy startup files to that location.
     dir.create(file.path(dir_start,'www'), showWarnings=F)
     saveRDS(object = init,file=file.path(dir_start,"init.rds"))
     file.copy(system.file(file.path("rmd","app.Rmd"),package = "shinyscreen"),file.path(dir_start,"app_run.Rmd"))