Made some functions use less DOM searching.