Convert mostly to rails4 (except tests)