improved cleanup for log parsing