Fix bugs caught by static analysis
Fix various PHP code bugs found using static analysis (#1489086)
Fix display issue on addressbooks/groups list (#1489039)