Fix a whole chunk of bugs.