import re


def get_max_age(headers):
    """Parse the 'max-age' directive from the 'CACHE-CONTROL' header.
    
    Arguments:
    headers -- dictionary of HTTP headers

    Return the parsed value as an integer, or None if the 'max-age' directive
    or the 'CACHE-CONTROL' header couldn't be found, or if the header is
    invalid in any way.

    """
    ret = None
    cache_control = headers.get('CACHE-CONTROL')
    if cache_control:
        parts = re.split(r'\s*=\s*', cache_control)
        if len(parts) == 2 and parts[0] == 'max-age' and re.match(r'^\d+$',
                                                                  parts[1]):
            ret = int(parts[1])
    return ret