Fixed bugs, modified codes