Fix MD indentation, make function private, optimise apply block