Numerous changes and rebasing