Some refectoring.