Replaced flatMap with map where appropriate...