Added support for remote backup

Plus refactoring, bug fixes and improvements