Few fixes and improvements for IDM and OAuth