MB-146 #Updated to match new code with order by statements and other changes.