Optimizations, mainly drastically reduced stack usage