Added some checks, and some mminor changes...