Remove views when not shown anymore. Some other refactorings.