Fixed bugs related to init function