Move to nested try blocks to support python 2.4