Refactoring and some progress with the backend