How to restore original android OS and remove cyanogenmod? My situation is that I downloaded cyanogenmod and liked it. I then performed a factory reset and wipe data off of my phone. When a restart my phone, I no longer have google play store installed or any of the stock google apps for that matter.

What has gone wrong and how do I restore everything back to the stock version of android?(the way it was when I didn't have cyanogenmod and just the plain old android OS)

My phone was a Sony Xperia Z. It is running on android 5.1.1.
Instead of trying to head back, why not flash GAPPS (Google Apps suite) if there's nothing wrong with CM itself? Get appropriate GAPPS for your Android version at opengapps.org.