fixes for issues #48 & #49

for indexing and querying