[cleanup] First step of cleanup. Now for tests and to fix all the new bugs.