refactor in preparation of linger
refactor cleanup code
implement actual linger
Merge pull request #25 from otalk/linger

Linger