Fix by Mitz Pettel, reviewed by Maciej.