Some cleanup in system and slightly optimized logging.