Multiple level support. Minor refactoring