ViewerInstance: fix warnings + add missing locks + add asserts