Major refactoring. Added support for restricted lists