Cleanup and optimize for speed/readability