Most of the code is rewritten.