Fix bugs and clean