fixes #11; added life cycle management