Temporary fix. This should fix some bugs

Please use previous commit as "stable". This changes not tested.