Looks like this part can have some more optimalization, but I don't dare to look at it until I have a possible testing environment; adding a FIXME