Various fixes, now it works