Various engine fixes

The collection of different non-critical engine fixes.

No changes in functionality, only increase in stability and some minor performance optimizations.