Fixed patch for Surjection/InvertedSurjection; made code a bit cleaner.