Shorten code, fix global leak.