Merge Afshin's changes: fixing compilation errors