change function names to underscore style, and abstract out a couple hardcoded constants