Made a number of changes and improvements. See the readme for more information.