Lots of modifications. Again, sorry for big commit, rushed