fix phantoms and clean some code.