Functions fixed, all local tests pass