Also, I stumbled upon the following problem: HLPFILE_FreeCnt is never called! There is something bad with hlpfile->wRefCount - it's 4 (!) instead of 1 after just opening and closing file.
actually we should decrement the count for: - closing the window attached to a page - upon exit, remove references in history (and attached refcounts) that should help here (not sure I got them all though) A+