Bug fixes. Now logging exceptions correctly