Better logging and code format