Cleaned up code

Combined for loops
Combined various expressions