Added backup versions of working code before I mess up everything
Deleted obsolete functions