Code cleanup and minor fix in viewlib.