Added very robust exception handling