         else
             return (args...) => @logger.debug("kucalc.Project('#{@project_id}').#{f}", args...)
 
-    close: () =>
+    # free -- stop listening for status updates from the database and broadcasting
+    # updates about this project.
+    # NOTE: as of writing this line, this free is never called by hub, and idle_timeout_s
+    # is used instead below (of course, free could be used by maintenance operations).
+    free: () =>
+        # Ensure that next time this project gets requested, a fresh one is created, rather than
+        # this cached one, which has been free'd up, and will no longer work.
+        delete project_cache[@project_id]
+        # Close the changefeed, so get no further data from database.
         @synctable?.close()
         delete @synctable
         delete @logger
         delete @project_id
         delete @compute_server
         delete @host
+        delete @is_ready
+        # Make sure nothing else reacts to changes on this ProjectClient, since they won't happen.
+        @removeAllListeners()
 
     state: (opts) =>
         opts = defaults opts,

        opts = defaults opts,
            project_id : required
            cb         : required
        @dbg("project")("project_id=#{opts.project_id}")
        @database.synctable
            table    : 'projects'
            columns  : ['state', 'status', 'action_request']
            where    :
                project_id : opts.project_id
            cb       : (err, synctable) =>
                if err
                    opts.cb(err)
                else
                    opts.cb(undefined, new Project(@, opts.project_id, synctable, @logger))

class Project extends EventEmitter
    constructor: (@client, @project_id, @synctable, @logger) ->
        @host = "project-#{@project_id}"
        @dbg('constructor')
        @synctable.on 'change', => @emit('change')

    # Get the current data about the project from the database.
    get: (field) =>

    return new Client(db, logger)

class Dbg extends EventEmitter

project_cache = {}

class Client
    constructor: (@database, @logger) ->
