Fixed some bad code