Bug fixes and minor improvements

1 job for master in 6 minutes and 29 seconds (queued for 1 minute and 48 seconds)