Fix many little bugs and security problems.