Cleanup, and replaced ugly looping with sum()