Smart completion: some code improvements