refactored storeNode and related functions a bit