More refactoring

Moved logger out into utils lib.
Fixed potential crash when opening image that was deleted.