Sorting the ADP and moving some code around.