Separed validation in two steps and added orientation fixing.