Add some profiling code
Fix a bug in tab completion