Few fixes

It's still broken I think, but at least now should work a bit better.