Reorg code into separate files
Use client object for callbacks
Use yajl to format the output as JSON