implemented revert command. Many bug fixes.