Added some code fixing and new self tests.