Code rewrite, version 4.0.0