Fix #282 and implement a better validator