Expiration was incorrectly used in place of msg_type
Check for 'is None' explicitly so 0 and other non-True values are accepted