Fix #924 (for real this time): Build system does not always identify modules correctly, refs #993