Allowing result fields to be used as arguments for queries
A few minor fixes and cleanup