Fixed some very heinous bugs