Auto purging and bugfixes

AccessStack can now automatically purge expired/invalid objects. This can be
turned on/off through the :auto_purge parameter.

Fixed indefinite lock in the threadsafe() method. If the mutex has already
aquired a lock and threadsafe() is called again, it will ignore the lock code.
Such conditions only happen in situations when threadsafe() calls are nested.