Some bugfixes and reflection optimizations