redundancy removals and fixed bugs