Split shell.py into multiple classes and added an API