fix toplevel completion (show std classes and packages), minor refactoring