Try/except block amendments

Ensured that any code that could possibly fail was properly contained
in the try/except blocks to accommodate exceptions properly.