Remove bug in toolkit and clear code