Added scan command, reworked API for executing scan and query commands.