Simplify intpow and clean up