This will only happen if an error happens in a proc (or if the proc is badly written) and it doesn't release the handle it grabs. In general, procedures should grab from the subquery pool and release their handle before they exit.
As for adding a comment link and such, I believe there is a special ADP tag (or a tcl proc) that will automatically add these. Check the ad-html.tcl file.