Refactored to more stable and safety architecture.