Fixed some bugs after testing with the CMS project.