Support SmartVar Queries

This closes #1, #4 and #5