I don't know what this function is supposed to do; definitely this is more correct than what's there. This closes #22.