Fixed logging and exceptions