some fixes to make generating passwords work on older versions of php