Various bug fixes and texture optimizations