style, cleanups, and added close