Restructured directories and some code refactoring