Fixed up code mess