fixed several bugs in provisioning.