A bunch of bug fix.