Replaced upward-pass functions with optimized versions.