What were the main motivations behind the passage of black codes in the Southern states?