Fix some logic, some security changes, coding standards.