Added kazuyukitanimura's algorithm simplifications. Fixed some types in README.