Improve error handling when failing to create a logwriter
Clean up error handling in main.c