So far working code (with the crazy rotation sometimes).