Fixed some unseen bugs and moved a line