fixed some bugs related to initialization