Fixed #341, 342 and 343