Change some type names, clean up some flatMap calls