major fix on bugs detected by validator