moved all code from Relation.js to Field.js (TODO: doc)