Several minor changes addressing (potential) bugs and performance issues.