Port templates scale + NPE fixes