Major refactoring. Stable.