Fixed some bugs and changed some constants.