Refactor code.

- Only create self.close in self.link(); eliminates extra ref to scope.
- Declare some functions externally to reduce compile churn and
  improve readibility, etc.
Release 0.0.28.