Moved detection of removed parameters to updateDevice function plus other organization and optimization changes