Fixes memory leak when retrieving credentials

Fixes #21