generalize settings and fix some bugs. works for apache now.