Fixed compilation errors. Some tree functions need to be fixed.