Removed some vunerabilities and fixed other bugs