performance tuned

The object of these commits is for performance. Most of them are reported on http://trac.wildfiregames.com/ticket/1756, and some of them were added after that.