Tested and fixed bugs