Several fixes to support password encryption