Ported some changes of the trunk version of this file.

References #629.
Added $config:max-inactive-interval-in-minutes variable.

References #586.