Update changed arrays to vectors etc, deleted unused code, lots of type casting added