Core implementation.