Some changes for rails 4.1 and devise compatibility