Cleaning up comments and adding checks