Fixed a few bugs that seem to have arisen from a previous commit having
been deleted due to a forced update.