Fix some issues raised by @keradus