Finally working!

I think it's done, but we need to test it.