Very difficult and extensive adaptions, it took at least 3 hours to code this.
Please handle with care!