Fix the issues found in the static analysis

Have not fixed:
* #def127 - A lot of the crypto code is not checking the return value when finalizing the operation during error handling. Should we fix this?
* #def128 - See above.
* #def131 - The case should have a fall through.