@SuppressWarnings("unchecked")
	public GridSpace(Settings settings, int width, int height, Class siteClass) {
		this.settings = settings;

		if (width < 1)
			throw new IllegalArgumentException("width must be > 0");
		if (height < 1)
			throw new IllegalArgumentException("height must be > 0");
		if (siteClass == null)
			siteClass = Site.class;

		this.width=width;
		this.height=height;

		sites = new Site[height*width];

		Constructor siteConstructor;
		try {
			siteConstructor = siteClass.getConstructor(Integer.class, GridSpace.class);
		} catch (NoSuchMethodException ex) {
			throw new IllegalArgumentException(ex);
		}

		try {
			// Creates nodes and adds to the HashMap
			for (int i = 0; i < height; i++) {
				for (int j = 0; j < width; j++) {
					int id = (i * width) + j;
					sites[id] = (Site)siteConstructor.newInstance(id, this);
				}
			}
		} catch (Throwable ex) {
			throw new IllegalArgumentException(ex);
		}
	}