Fixed serious security bugs and some coding standard flaws.