removed most globals