Fixed a few bugs that were introduced in the last commit