Fixed a couple of bugs and added missing files