Removed unused code.
Simplified loops.
Make codacy happier.