Added some guard code and minor name fixes