fix undefined calls in datastore service, fix loops