Did a lot of changes, should work ok now, but quite slow performance...