Fix type issues with modular power, and extend the algorithm for nested powers
Fix type issues with modular power, and extend the algorithm for nested powers

kaushik94/sympy,kaushik94/sympy,kaushik94/sympy