Updated and reoganized functions to have sensible names.