Refactored a little bit more, introduced a few bugs into the shell, need a better shell