Change file descriptors and add functions