Several fixed bugs