Fix bugs

Clear locks in cleanup function, install-device