Updated cloud code

Many queries have been improved