implemented dispose pattern

Fixes #214