Encapsulated exception handling. Added comments and todo.