Fix speed and compiling problems.