Added better filepath extension support

Changed (++) and the use of an intermediary function to use "replaceExtension" instead.