Move more code into try-except for greater safety