Got rid of some terribly inefficient helper functions.