Bug fixes. Fixed some obvious mistakes I made in the last commit. Sorry.