fix a lot of little bug around the new code