Fixed issues with the open() function.