Fixed a minor bug and added a few functions.