use t.reference instead of t.integer now
use select rather than :only in as_json to improve perf, and fix bugs