Thanks to Denis Kryskov, several BUGs are fixed.