some restructuring of internal stuff