Added validation, some bugs fixed