Trim function and other changes.