Fixed error msg bugs and crash viewer window