Auto orientation

(note: this PR depends on #17 and #18)