Change Hashtable and HashSet to LinkedHashMap and LinkedHashSet.
Fixed lots of warnings about generics and changed from Iterator to foreach loops