updated for PHP warnings (ln 465) and missing js