Fixed coordinate confusion, removed redundant direction processing