Fixed problems pointed out by @Vesuri