Yes you can enter a sub for the DP. As for the DP and Flex switching, if the DP plays defense for the flex, the flex has left the game and it counts as a substitution for the flex. If you bat the flex for the DP, the DP has left the game and it is considered a substitution for the DP.