--- a/R/jags.R
+++ b/R/jags.R
@@ -6,7 +6,7 @@
 print.jags <- function(x, ...)
 {
   cat("JAGS model:\n\n")
-  
+
   model <- x$model()
   for (i in 1:length(model)) {
     cat(model[i],"\n",sep="")
@@ -40,7 +40,7 @@
     else if (!inherits(file, "connection")) {
       stop("'file' must be a character string or connection")
     }
-    
+
     ## JAGS library requires a physical file, so we need to copy
     ## the contents of the connection to a temporary file
     model.code <- readLines(file, warn=FALSE)
@@ -51,8 +51,8 @@
         .quiet.messages(TRUE)
         on.exit(.quiet.messages(FALSE), add=TRUE)
     }
-    
-    p <- .Call("make_console", PACKAGE="rjags") 
+
+    p <- .Call("make_console", PACKAGE="rjags")
     .Call("check_model", p, modfile, PACKAGE="rjags")
 
     varnames <- .Call("get_variable_names", p, PACKAGE="rjags")
@@ -85,7 +85,7 @@
     else {
         stop("data must be a list or environment")
     }
-    
+
     .Call("compile", p, data, as.integer(n.chains), TRUE, PACKAGE="rjags")
 
 ### Setting initial values
@@ -102,7 +102,7 @@
 
             if (any(duplicated(inames)))
                 return (FALSE)
-            
+
             if (any(inames==".RNG.name")) {
                 rngname <- inits[[".RNG.name"]]
                 if (!is.character(rngname) || length(rngname) != 1)
@@ -120,10 +120,10 @@
 
             if (!all(sapply(inits, is.numeric)))
                 return (FALSE)
-            
+
             return (TRUE)
         }
-        
+
         setParameters <- function(inits, chain) {
             if (!is.null(inits[[".RNG.name"]])) {
                 .Call("set_rng_name", p, inits[[".RNG.name"]],
@@ -133,9 +133,9 @@
             .Call("set_parameters", p, inits, as.integer(chain),
                   PACKAGE="rjags")
         }
-        
+
         init.values <- vector("list", n.chains)
-        
+
         if (is.function(inits)) {
             if (any(names(formals(inits)) == "chain")) {
                 for (i in 1:n.chains) {
@@ -166,7 +166,7 @@
                 init.values <- inits
             }
         }
-            
+
         for (i in 1:n.chains) {
             if (!checkParameters(init.values[[i]])) {
                 stop("Invalid parameters for chain ", i)
@@ -201,7 +201,7 @@
                       .Call("get_iter", p, PACKAGE="rjags")
                   },
                   "sync" = function() {
-                      
+
                       model.state <<- .Call("get_state", p, PACKAGE="rjags")
                   },
                   "recompile" = function() {
@@ -235,7 +235,7 @@
                           if(n.adapt > 0 && adapting) {
                               cat("Adapting\n")
                               .Call("update", p, n.adapt, PACKAGE="rjags")
-                              if (!.Call("adapt_off", p, PACKAGE="rjags")) {
+                              if (!.Call("check_adaptation", p, PACKAGE="rjags")) {
                                   warning("Adaptation incomplete");
                               }
                           }
@@ -246,7 +246,8 @@
     class(model) <- "jags"
 
     if (n.adapt > 0) {
-        adapt(model, n.adapt)
+        ok <- adapt(model, n.adapt)
+        if (!ok) warning("Adaptation incomplete")
     }
     return(model)
 }
@@ -326,7 +327,7 @@
 
     if (!is.character(variable.names) || length(variable.names) == 0)
       stop("variable.names must be a character vector")
-     
+
     if (!is.numeric(n.iter) || length(n.iter) != 1 || n.iter <= 0)
       stop("n.iter must be a positive integer")
     if (!is.character(type))
@@ -369,7 +370,7 @@
         stop("invalid name")
     if (length(state) != 1)
         stop("invalid state")
-    
+
     type <- match.arg(type, c("sampler","rng","monitor"))
     .Call("set_factory_active", name, type, as.logical(state), PACKAGE="rjags")
 }
@@ -378,7 +379,7 @@
 {
     ## Utility function used to get the names of the individual elements
     ## of a node array
-  
+
     if (prod(dim) == 1)
       return(basename)
 
@@ -403,7 +404,7 @@
             }
         }
     }
-    
+
     indices <- as.character(lower[1]:upper[1])
     if (ndim > 1) {
         for (i in 2:ndim) {
@@ -417,7 +418,7 @@
 {
     if (!inherits(model, "jags"))
       stop("Invalid JAGS model object in nchain")
-    
+
     .Call("get_nchain", model$ptr(), PACKAGE="rjags")
 }
 
@@ -440,9 +441,9 @@
             }
             vardim <- d[1:(length(d)-2)]
             nvar <- prod(vardim)
-            niter <- d[length(d) - 1]        
+            niter <- d[length(d) - 1]
             nchain <- d[length(d)]
-            
+
             values <- as.vector(out[[i]])
             var.i <- matrix(NA, nrow=niter, ncol=nvar)
             for (j in 1:nvar) {
@@ -451,7 +452,7 @@
             vnames.ch <- c(vnames.ch, coda.names(varname, vardim))
             ans.ch[[i]] <- var.i
         }
-        
+
         ans.ch <- do.call("cbind", ans.ch)
         colnames(ans.ch) <- vnames.ch
         ans[[ch]] <- mcmc(ans.ch, start=start, thin=thin)
@@ -467,7 +468,7 @@
         ## later versions.
         return(invisible()) #Module already loaded
     }
-    
+
     if (missing(path)) {
         path = getOption("jags.moddir")
         if (is.null(path)) {