Fixed two bugs that are needed to reproduce profiling numbers