Fixed some poor code