Refactored client connection and provisioning code into singleton objects.
Added in ability to handle LastChunk.
Some additional simplifications.