Modified to run properly from the command line.