long rollingsStock = 0;
    public static BalanceSheet generateBalanceSheet(ReadOnlyWorld w,	    FreerailsPrincipal p, boolean proForma) {	int year;	GameTime now = (GameTime) w.get(ITEM.TIME, Player.AUTHORITATIVE);	GameCalendar calendar = (GameCalendar) w.get(ITEM.CALENDAR,		Player.AUTHORITATIVE);	year = calendar.getCalendar(now).get(GregorianCalendar.YEAR);	BankAccount account = (BankAccount) w.get(KEY.BANK_ACCOUNTS, 0, p);	long cash = account.getCurrentBalance();	long overdraft;	if (cash < 0) {	    overdraft = -cash;	    cash = 0;	} else {	    overdraft = 0;	}	long rollingsStock = 0;	long trainMaintenance = 0;	long rollingStock = 0;	TrainModelViewer tmViewer = new TrainModelViewer(w);	NonNullElements i = new NonNullElements(KEY.TRAINS, w, p);	while (i.next()) {	    tmViewer.setTrainModel((TrainModel) i.getElement());	    rollingStock += tmViewer.getBookValue();	    trainMaintenance += tmViewer.getMaintenance();	}	long property = 0;	int width = w.getMapWidth();	int height = w.getMapHeight();	TerrainTileViewer ttv = new TerrainTileViewer(w);	TrackPieceViewer tpv = new TrackPieceViewer(w);	int trackRules[] = new int	    [w.size(KEY.TRACK_RULES, Player.AUTHORITATIVE)];	for (int x = 0; x < width; x++) {	    for (int y = 0; y < height; y++) {		FreerailsTile tile = w.getTile(x, y);		if (tile.getOwner().equals(p)) {		    ttv.setFreerailsTile(x, y);		    tpv.setFreerailsTile(x, y);		    property += ttv.getBookValue();		    property += tpv.getBookValue();		    trackRules[tile.getTrackRule().getRuleNumber()]++;		}	    }	}	StationModelViewer smv = new StationModelViewer(w);	i = new NonNullElements(KEY.STATIONS, w, p);	while (i.next()) {	    smv.setStationModel((StationModel) i.getElement());	    property += smv.getBookValue();	}	long trackMaintenance = 0;	for (int j = 0; j < trackRules.length; j++) {	    TrackRule tr = (TrackRule) w.get(KEY.TRACK_RULES, j,		    Player.AUTHORITATIVE);	    trackMaintenance += trackRules[j] * tr.getMaintenanceCost();	}	BankAccountViewer bav = new BankAccountViewer(w);	bav.setBankAccount(account);	long tax = bav.getIncomeTaxLiability();	long interest = account.getCurrentBalance();	if (interest < 0) {	    interest = (long) (interest * -bav.getOverdraftInterestRate());	} else {	    interest = 0;	} 	long loans = 0;	long bonds = 0;	long stock = 0;	long investedCapital = bav.getOutsideInvestment();		return new BalanceSheet(year - 1, proForma, cash, rollingsStock,		property, overdraft, interest, trackMaintenance,		trainMaintenance, tax, loans, bonds, stock, investedCapital);    }