[cyril] move direction related code to extension.