Added logic to deal with incorrect termination dates (port out)