Fixed bug with unknow view id, general tidy up