Initial commit for plugin revamp to support Cloud.
Quick reorder of fail logic.