Move storage to commands and some refactoring