A lot of refactoring. Preparing for new features!