Fix some logic failures
Merge remote-tracking branch 'origin/devel' into devel