cleanup completion code a bit