Fixed some SECURITY_ATTRIBUTES handling and the inherit flag in general.