Fixed a bunch of bugs and made restoration better