Added some more exception safety, just in case