Removed useless code + modularization