Reorganization of the code to make it more modular.

TODO: Implement listShuffle