refactored some of the nested for loop mess in getProperties, fixes #156