More refacoring of code