Code factoring + clean.