Something got corrupted in one of my .iml files. Rebuilt the project from the gradle files and everything is ok. We should definitely add .iml to the gitignore.
added some comments to Mikes code, and some stuff to gitignore.