start implement protocol and direction handling, fix warning in layout