A few tweaks for safari.

A fix for the safari bug - somehow the string concatenation was causing problems. I'm pretty curious to track it down, but after looking for 5 minutes, not sure what could be causing it.

Also pulled out a couple of static items to avoid recomputation. Runs reasonably in Safari now. Probably could be much, much faster though, but not sure where. Will probably need to ask some others to figure it out from profiling.