factor does not work as expected



  declare and assume have no effect on factor or ratsimp.
ratsimp(h) is probably unnecessary.

you could try

subst(h^3,8,%)
subst(h^2,4,%)
subst(h,2,%)
subst(2,h,%)

There is a function hipow you could use for the 2nd part.