Added some comments to the prepare_surfaces function for clarity.