Unused code, and remove globals