Optimizations and bug fixes

Optimized the system for large numbers of objects.  Now uses about 1/3
the amount of memory without much slowdown.

Also fixed a few obvious visual bugs.