changes in many functions, to reducing external coupling with php