3d-viewer: code cleaning and minor bug fix.