Removed excess and fixed bugs