Fixed all warnings and static analyzer errors.