reworked loading for generality and testing
merged upstream