CLOUDIFY-1397 better exception handling and cleanup. this is getting a bit messy, need to revise with barak on a cleaner way to go about this