Some fixes from @tobami