Fixed a couple of functions