Fixed a bunch of bugs and mistypes