Fixed bugs, added validations