Made logging and error handling work