Multiple fixes

https://github.com/WindowsAzure/azure-sdk-tools-xplat/issues/458
https://github.com/WindowsAzure/azure-sdk-tools-xplat/issues/529
https://github.com/WindowsAzure/azure-sdk-tools-xplat/issues/513
https://github.com/WindowsAzure/azure-sdk-tools-xplat/issues/511
https://github.com/WindowsAzure/azure-sdk-tools-xplat/issues/510