Some progress.
Still does not work properly.