Added database initialisation, switching of states, changing and changing of device names