refactored to make all functions overridable via config.