Address some bugs