port line from newnewui, some cleanups