moved redirectlog stuff to a function, and added a $quietmode variable which is checked when the functions are called.