Added global func, some changes.