Fixed compilation errors. Merged code.