add privileges management and fixed bugs