Updated code to make it compatible with the latest dev channel build and corrected some bugs