Validation logic has been improved. Can check in 4 direction orientations. A few bugs are left, though.