added graph in header, also minor performance improvements