Clean up numerical code and add general power method.