Fix protocol not being set correctly, closes #230.

Also account for errors when creating temp dirs.