WIP (damn, it's getting more and more complex)