Some added exception handling. Must be improved further.

Change-Id: I31870bab390e2f5826db7e862439cc58d4017d9e