Updated code getting close to using auth.
Committing now because master is about to change a lot and our stable changes should be merged in sooner rather than later.