Fix a crapton of bugs.