minor whitespace adjustment
clean up repository implementation and fix some possible memory leaks