Some refractoring done.