Massive refactoring + FOL for Rails