Restored changes from 300be368f5c9dcf584a0be59e5abc1b3f62e0d75