Added type coercion for integer fields
Updated for resolving references
Fix for creating queries